var a = getApp(), e = void 0;

Page({
    data: {
        order: {}
    },
    openlocation: function(a) {
        var e = a.currentTarget.dataset.type;
        wx.openLocation({
            latitude: 1 == e ? this.data.order.start_address.latitude : this.data.order.end_address.latitude,
            longitude: 1 == e ? this.data.order.start_address.longitude : this.data.order.end_address.longitude,
            name: 1 == e ? this.data.order.start_address.formatted_addresse : this.data.order.end_address.formatted_addresse
        });
    },
    makePhoneCall2: function(a) {
        var e = a.currentTarget.dataset.type;
        wx.makePhoneCall({
            phoneNumber: 1 == e ? this.data.order.start_address.phone : this.data.order.end_address.phone
        });
    },
    onLoad: function(a) {
        (e = this).setData({
            order_no: a.order_no
        });
    },
    onShow: function() {
        e.getOrder(this.data.order_no);
    },
    getOrder: function(d) {
        wx.showLoading({
            title: "加载中"
        }), a.com.post("wx/order/find", {
            order_no: d
        }, function(a) {
            wx.hideLoading(), 0 === a.errno && ("nearby" != a.data.start_address && (a.data.start_address = JSON.parse(a.data.start_address)), 
            a.data.end_address = JSON.parse(a.data.end_address), a.data.filterDistance = (a.data.distance / 1e3).toFixed(2), 
            e.setData({
                order: a.data
            }), 0 != a.data.ws_id && e.getService(a.data.ws_id));
        });
    },
    makePhoneCall: function() {
        wx.makePhoneCall({
            phoneNumber: this.data.phone
        });
    },
    cancelOrder: function() {
        wx.navigateTo({
            url: "/pages/order/cancel/cancel?order_id=" + this.data.order.id + "&order_no=" + this.data.order.order_no + "&type=2"
        });
    },
    getService: function(d) {
        a.com.post("wx/service/orderfind", {
            ws_id: d
        }, function(a) {
            0 === a.errno && e.setData(a.data);
        });
    }
});